package com.canton.dao.repository;

import com.canton.dao.entity.ImageNode;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.List;

@Repository
public interface ImageRepository extends Neo4jRepository <ImageNode,Long>, CrudRepository<ImageNode,Long> {



    ImageNode findByName(@Param("name") String name);

    //模糊查询
    @Query("match (n:图像) where n.名称 =~ ('.*'+$likes+'.*') return n")
    List<ImageNode> findByNameLike(@Param("likes") String likes);
    //查询所有节点
    List<ImageNode> findAll();

//    查图像
    @Query("MATCH (m)-[r]->(a:图像) Where m.名称=($name)  RETURN m,r,a LIMIT $limit")
    Collection<ImageNode> findAllLimitBy(@Param("name") String name,@Param("limit") int limit);

}
